package com.order.feign.fallback;

import com.demo.common.entity.ShoppingCart;
import com.demo.common.response.Result;
import com.order.feign.client.OrderServiceClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


/**
 * @author why
 * @description
 * @date 2025/8/19 14:00
 */
@Slf4j
@Component
public class OrderServiceClientFallback implements FallbackFactory<OrderServiceClient> {

    @Override
    public OrderServiceClient create(Throwable cause) {
        return new OrderServiceClient() {
            @Override
            public Result getOrder(Long id) {
                log.error("获取订单[{}]失败：{}", id, cause.getMessage());
                return Result.success(new ShoppingCart());
            }
        };


    }
}
